/*
 * BanBu_DigiCell
 * @description 本文件提供附近广播界面的单个广播的定制cell
 * @package
 * @author 		***
 * @copyright
 * @version 		1.0
 * @description 本文件提供附近广播界面的单个广播的定制cell
 */

#import "BanBu_DigiCell.h"
#import "BanBu_ImageView.h"
#import "BanBu_PersonDataViewController.h"

@implementation BanBu_DigiCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        //-setMasksToBounds:方法告诉layer将位于它之下的layer都遮盖住。这是必须的，这样会使圆角不被遮，但是这样会导致阴影效果没有，很多网上都给出资料，再添加一个SubLayer，添加阴影。
//        NSLog(@"%f",self.frame.size.width); 
        _shadowView = [[UIView alloc]initWithFrame:CGRectZero];

        [self.contentView addSubview:_shadowView];
        [_shadowView release];
        
        
        bkView = [[BanBu_ImageView alloc]initWithBackGroundImageType:UIImageViewCreatTypeCell imageName:@"listbg(2).png"];
        bkView.userInteractionEnabled = YES;

        [_shadowView addSubview:bkView];
        [bkView release];
        
        //*************************************************************/
        

        //头像
        _iconButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _iconButton.frame = CGRectMake(10, 10, 38, 38);
        
        _iconButton.layer.cornerRadius = 17.5;
        _iconButton.layer.masksToBounds = YES;
        [_iconButton addTarget:self action:@selector(pushProfile:) forControlEvents:UIControlEventTouchUpInside];

        [_shadowView addSubview:_iconButton];
        
        //vip图标
        _vipImageView = [[UIImageView alloc] initWithFrame:CGRectMake(9, 9, 40, 42)];
        
        [_shadowView addSubview:_vipImageView];
        [_vipImageView release];
        //名字
        _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(55, 10, 160, 17)];
        _nameLabel.backgroundColor = [UIColor clearColor];
//        _nameLabel.text = @"Yumi Lai and 张三";
        _nameLabel.font = [UIFont boldSystemFontOfSize:13];
        _nameLabel.textColor = [UIColor blackColor];
        [_shadowView addSubview:_nameLabel];
        [_nameLabel release];
        
        //距离标志
        _distanceBack = [[UIImageView alloc]initWithFrame:CGRectMake(55, 30, 10, 14)];
        NSString *signatureBackpath = [[NSBundle mainBundle] pathForResource:@"distance_mark" ofType:@"png"];
        _distanceBack.image =  [UIImage imageWithContentsOfFile:signatureBackpath];
        [_shadowView addSubview:_distanceBack];
        [_distanceBack release];

        
        //距离与到达时间
        _distanceAndTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(68, 29, 160, 16)];
        _distanceAndTimeLabel.backgroundColor = [UIColor clearColor];
        _distanceAndTimeLabel.font = [UIFont boldSystemFontOfSize:13];
        _distanceAndTimeLabel.textColor = UIColorWithRGB(150, 150, 150, 1.0);
        [_shadowView addSubview:_distanceAndTimeLabel];
        [_distanceAndTimeLabel release];
        
        //性别和年龄
        //年龄和性别
        _sexImgV = [[UIImageView alloc]initWithFrame:CGRectMake(145, 29, 13, 13)];
        [_shadowView addSubview:_sexImgV];
        [_sexImgV release];
        
        _ageLabel = [[UILabel alloc]initWithFrame:CGRectMake(161, 29, 50, 16)];
        _ageLabel.backgroundColor = [UIColor clearColor];
		_ageLabel.font = [UIFont systemFontOfSize:13];
		_ageLabel.textColor = UIColorWithRGB(150, 150, 150, 1.0);
		[_shadowView addSubview:_ageLabel];
        [_ageLabel release];
        NSString *verifypath = [[NSBundle mainBundle] pathForResource:@"verify_card" ofType:@"png"];
        _verify = [[UIImageView alloc]initWithImage:[UIImage imageWithContentsOfFile:verifypath]];
        _verify.frame = CGRectMake(90, 31, 15, 10);
        //        _verified.backgroundColor = [UIColor redColor];
        _verify.hidden = YES;
        [_shadowView addSubview:_verify];
        [_verify release];


        //最新上线时间
        _lastTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(215, 10, 75, 17)];
        _lastTimeLabel.backgroundColor = [UIColor clearColor];
//        _lastTimeLabel.text = @"1天前";
        _lastTimeLabel.textAlignment = kTextAlignmentRight;
        _lastTimeLabel.font = [UIFont boldSystemFontOfSize:13];
        _lastTimeLabel.textColor = UIColorWithRGB(150, 150, 150, 1.0);
        [_shadowView addSubview:_lastTimeLabel];
        [_lastTimeLabel release];
        
        //文字（可选）
        _sayTextLabel = [[UILabel alloc]initWithFrame:CGRectMake(55, 44, 235, 0)];
//       _sayTextLabel.text = @"你没，你没，你没没，你没，你没没，你没，你没没，你没，你没没，你没，你没，都";
        _sayTextLabel.textColor = [UIColor blackColor];
        _sayTextLabel.font = [UIFont boldSystemFontOfSize:13];
        _sayTextLabel.backgroundColor = [UIColor clearColor];
//        textLabelHeight = [_sayTextLabel.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 100) lineBreakMode:NSLineBreakByTruncatingMiddle].height;
//        _sayTextLabel.frame = CGRectMake(55, 44+10, 235, textLabelHeight);
        _sayTextLabel.numberOfLines = 0;
        [_shadowView addSubview:_sayTextLabel];
        [_sayTextLabel release];
        
        //标签view
        _tagsView = [[UIView alloc]initWithFrame:CGRectZero];
        _tagsView.backgroundColor = [UIColor clearColor];
        [_shadowView addSubview:_tagsView];
        [_tagsView release];
 
        //电话
        _telButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _telButton.frame = CGRectMake(75, 55, 120, 10);
        [_telButton addTarget:self action:@selector(callThePhoneNumber) forControlEvents:UIControlEventTouchUpInside];
        _telButton.titleLabel.textAlignment = kTextAlignmentLeft;
        [self.contentView addSubview:_telButton];

        
        _telLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _telLabel.text = NSLocalizedString(@"phoneNumber", nil);
        _telLabel.backgroundColor = [UIColor clearColor];
        _telLabel.textAlignment = kTextAlignmentCenter;
        _telLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_telLabel];
        
        
        //网址
        _netAdress = [UIButton buttonWithType:UIButtonTypeCustom];
        _netAdress.frame = CGRectZero;
        [_netAdress addTarget:self action:@selector(goToUrl:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_netAdress];
        
        _netLabel = [[UILabel alloc] initWithFrame:CGRectMake(55, 55,30,30)];
        _netLabel.text = NSLocalizedString(@"URL : ", nil);
        _netLabel.backgroundColor = [UIColor clearColor];
        _netLabel.textAlignment = kTextAlignmentCenter;
        _netLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_netLabel];
        

        
        //主图片
        _headImageView = [[UIImageView alloc]initWithFrame:CGRectZero];
        _headImageView.userInteractionEnabled = YES;
//        _headImageView.backgroundColor = [UIColor whiteColor];
//        _headImageView.image = [UIImage imageNamed:@"photo_default.png"];
//        _headImageView.layer.cornerRadius = 6.0;
//        _headImageView.layer.masksToBounds = YES;
        [_shadowView addSubview:_headImageView];
        [_headImageView release];
        
        //播放按钮(可选)
        _playButton = [UIButton buttonWithType:UIButtonTypeCustom];
//        _playButton.hidden = YES;
//        _playButton.frame = CGRectMake( 150-105/2, _shadowView.frame.size.height-13, 105, 26);
//        [_playButton setImage:[UIImage imageNamed:@"播放语音_未按下_不空.png"] forState:UIControlStateNormal];

        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(playAction:)];
        [_playButton addGestureRecognizer:tap];
        [tap release];
        [_shadowView addSubview:_playButton];
 
        _soundTimeLabel = [[UILabel alloc]initWithFrame:CGRectZero];
//        _soundTimeLabel.hidden = YES;
        _soundTimeLabel.backgroundColor = [UIColor clearColor];
        _soundTimeLabel.textColor = [UIColor whiteColor];
        _soundTimeLabel.font = [UIFont systemFontOfSize:14];
        _soundTimeLabel.textAlignment= kTextAlignmentRight;
        [_shadowView addSubview:_soundTimeLabel];
        [_soundTimeLabel release];
        
        //评论（可选）
        _commentView = [[UIView alloc]initWithFrame:CGRectMake(10, _shadowView.frame.origin.y, 300, 0)];
        _commentView.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:_commentView];
        [_commentView release];
        
//        _numLabel = [[UILabel alloc]initWithFrame:CGRectZero];
//        [self.contentView addSubview:_numLabel];
//        [_numLabel release];
      
        /********没辙了*********/
        {
            //头像
            _iconBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
            _iconBtn1.frame = CGRectZero;
            _iconBtn1.layer.cornerRadius = 17.5;
            _iconBtn1.layer.masksToBounds = YES;
            [_iconBtn1 addTarget:self action:@selector(pushProfile:) forControlEvents:UIControlEventTouchUpInside];

            [self.commentView addSubview:_iconBtn1];
            //姓名
            _nameLabel1 = [[UILabel alloc]initWithFrame:CGRectZero];
            _nameLabel1.backgroundColor = [UIColor clearColor];
            _nameLabel1.font = [UIFont boldSystemFontOfSize:13];
            _nameLabel1.textColor = [UIColor blackColor];
            
            [self.commentView addSubview:_nameLabel1];
            [_nameLabel1 release];
            
            //语音
            _voiceBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
            _voiceBtn1.frame = CGRectZero;
//            [_voiceBtn1 setImage:[UIImage imageNamed:@"广播详情-复选框-播放.png"] forState:UIControlStateNormal];
            [_voiceBtn1 addTarget:self action:@selector(play:) forControlEvents:UIControlEventTouchUpInside];
            [self.commentView addSubview:_voiceBtn1];
            
            _soundTimeLabel1 = [[UILabel alloc]initWithFrame:CGRectZero];
            _soundTimeLabel1.backgroundColor = [UIColor clearColor];
            _soundTimeLabel1.textColor = [UIColor whiteColor];
            _soundTimeLabel1.font = [UIFont systemFontOfSize:14];
            _soundTimeLabel1.textAlignment= kTextAlignmentRight;
            [self.commentView addSubview:_soundTimeLabel1];
            [_soundTimeLabel1 release];
            
            //文字
            _textLabel1 =  [[UILabel alloc]initWithFrame:CGRectZero];
            _textLabel1.textColor = [UIColor blackColor];
            _textLabel1.numberOfLines = 2;
            _textLabel1.font = [UIFont systemFontOfSize:13];
            _textLabel1.backgroundColor = [UIColor clearColor];
            [self.commentView addSubview:_textLabel1];
            [_textLabel1 release];
            
            _replyNameLabel1 = [[UILabel alloc]initWithFrame:CGRectZero];
            _replyNameLabel1.textColor = [UIColor blueColor];
            _replyNameLabel1.numberOfLines = 1;
            _replyNameLabel1.lineBreakMode = kTextLineBreakByTruncatingMiddle;
            _replyNameLabel1.font = [UIFont systemFontOfSize:13];
            
            _replyNameLabel1.backgroundColor = [UIColor whiteColor];
            _replyNameLabel1.backgroundColor = [UIColor clearColor];
            [self.commentView addSubview:_replyNameLabel1];
            _textLabel1.userInteractionEnabled = YES;
            _replyNameLabel1.userInteractionEnabled = YES;
            [_replyNameLabel1 release];

            UITapGestureRecognizer *replyPress1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(seeProfile:)];
            [_replyNameLabel1 addGestureRecognizer:replyPress1];
            
            //时间
            _timeLabel1 = [[UILabel alloc]initWithFrame:CGRectZero];
            _timeLabel1.backgroundColor = [UIColor clearColor];
            _timeLabel1.textAlignment = kTextAlignmentRight;
            _timeLabel1.font = [UIFont boldSystemFontOfSize:13];
            _timeLabel1.textColor = [UIColor lightGrayColor];
            [self.commentView addSubview:_timeLabel1];
            [_timeLabel1 release];
            
            _lineView1 = [[UIView alloc] initWithFrame:CGRectZero];
            _lineView1.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
            [self.commentView addSubview:_lineView1];
            [_lineView1 release];
        }
        {
            //头像
            _iconBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
            _iconBtn2.frame = CGRectZero;
            _iconBtn2.layer.cornerRadius = 17.5;
            _iconBtn2.layer.masksToBounds = YES;
            [self.commentView addSubview:_iconBtn2];
            [_iconBtn2 addTarget:self action:@selector(pushProfile:) forControlEvents:UIControlEventTouchUpInside];
            //姓名
            _nameLabel2 = [[UILabel alloc]initWithFrame:CGRectZero];
            _nameLabel2.backgroundColor = [UIColor clearColor];
            _nameLabel2.font = [UIFont boldSystemFontOfSize:13];
            _nameLabel2.textColor = [UIColor blackColor];
            
            [self.commentView addSubview:_nameLabel2];
            [_nameLabel2 release];
            
            //语音
            
                    
            _voiceBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
            _voiceBtn2.frame = CGRectZero;
//            [_voiceBtn2 setImage:[UIImage imageNamed:@"广播详情-复选框-播放.png"] forState:UIControlStateNormal];
            [_voiceBtn2 addTarget:self action:@selector(play:) forControlEvents:UIControlEventTouchUpInside];
            [self.commentView addSubview:_voiceBtn2];
            _soundTimeLabel2 = [[UILabel alloc]initWithFrame:CGRectZero];
            _soundTimeLabel2.backgroundColor = [UIColor clearColor];
            _soundTimeLabel2.textColor = [UIColor whiteColor];
            _soundTimeLabel2.font = [UIFont systemFontOfSize:14];
            _soundTimeLabel2.textAlignment= kTextAlignmentRight;
            [self.commentView addSubview:_soundTimeLabel2];
            [_soundTimeLabel2 release];

            //文字
            _textLabel2 =  [[UILabel alloc]initWithFrame:CGRectZero];
            _textLabel2.textColor = [UIColor blackColor];
            _textLabel2.numberOfLines =2;
            _textLabel2.font = [UIFont systemFontOfSize:13];
            _textLabel2.backgroundColor = [UIColor clearColor];
            [self.commentView addSubview:_textLabel2];
            [_textLabel2 release];
            
            
            //回复的人
            _replyNameLabel2 = [[UILabel alloc]initWithFrame:CGRectZero];
            _replyNameLabel2.textColor = [UIColor blueColor];
            _replyNameLabel2.numberOfLines = 1;
            _replyNameLabel2.lineBreakMode = kTextLineBreakByTruncatingMiddle;
            _replyNameLabel2.font = [UIFont systemFontOfSize:13];
            _replyNameLabel2.backgroundColor = [UIColor clearColor];
            [self.commentView addSubview:_replyNameLabel2];
            _textLabel2.userInteractionEnabled = YES;
            _replyNameLabel2.userInteractionEnabled = YES;
            [_replyNameLabel2 release];
            
            UITapGestureRecognizer *replyPress2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(seeProfile:)];
            [_replyNameLabel2 addGestureRecognizer:replyPress2];
            
            //时间
            _timeLabel2 = [[UILabel alloc]initWithFrame:CGRectZero];
            _timeLabel2.backgroundColor = [UIColor clearColor];
            _timeLabel2.textAlignment = kTextAlignmentRight;
            _timeLabel2.font = [UIFont boldSystemFontOfSize:13];
            _timeLabel2.textColor = [UIColor lightGrayColor];
            [self.commentView addSubview:_timeLabel2];
            [_timeLabel2 release];
            
            _lineView2 = [[UIView alloc] initWithFrame:CGRectZero];
            _lineView2.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
            [self.commentView addSubview:_lineView2];
            [_lineView2 release];
        }
        {
            //头像
            _iconBtn3 = [UIButton buttonWithType:UIButtonTypeCustom];
            _iconBtn3.frame = CGRectZero;
            _iconBtn3.layer.cornerRadius = 17.5;
            _iconBtn3.layer.masksToBounds = YES;
            [self.commentView addSubview:_iconBtn3];
            [_iconBtn3 addTarget:self action:@selector(pushProfile:) forControlEvents:UIControlEventTouchUpInside];
            //姓名
            _nameLabel3 = [[UILabel alloc]initWithFrame:CGRectZero];
            _nameLabel3.backgroundColor = [UIColor clearColor];
            _nameLabel3.font = [UIFont boldSystemFontOfSize:13];
            _nameLabel3.textColor = [UIColor blackColor];
            
            [self.commentView addSubview:_nameLabel3];
            [_nameLabel3 release];
            
            //语音
            
                     
            _voiceBtn3 = [UIButton buttonWithType:UIButtonTypeCustom];
            _voiceBtn3.frame = CGRectZero;
//            [_voiceBtn3 setImage:[UIImage imageNamed:@"广播详情-复选框-播放.png"] forState:UIControlStateNormal];
            [_voiceBtn3 addTarget:self action:@selector(play:) forControlEvents:UIControlEventTouchUpInside];
            [self.commentView addSubview:_voiceBtn3];
            _soundTimeLabel3 = [[UILabel alloc]initWithFrame:CGRectZero];
            _soundTimeLabel3.backgroundColor = [UIColor clearColor];
            _soundTimeLabel3.textColor = [UIColor whiteColor];
            _soundTimeLabel3.font = [UIFont systemFontOfSize:14];
            _soundTimeLabel3.textAlignment= kTextAlignmentRight;
            [self.commentView addSubview:_soundTimeLabel3];
            [_soundTimeLabel3 release];

            //文字
            _textLabel3 =  [[UILabel alloc]initWithFrame:CGRectZero];
            _textLabel3.textColor = [UIColor blackColor];
            _textLabel3.numberOfLines = 2;
            _textLabel3.font = [UIFont systemFontOfSize:13];
            _textLabel3.backgroundColor = [UIColor clearColor];
            [self.commentView addSubview:_textLabel3];
            [_textLabel3 release];
            
            //回复的人
            _replyNameLabel3 = [[UILabel alloc]initWithFrame:CGRectZero];
            _replyNameLabel3.textColor = [UIColor blueColor];
            _replyNameLabel3.numberOfLines = 1;
            _replyNameLabel3.lineBreakMode = kTextLineBreakByTruncatingMiddle;
            _replyNameLabel3.font = [UIFont systemFontOfSize:13];
            _replyNameLabel3.backgroundColor = [UIColor clearColor];
            [self.commentView addSubview:_replyNameLabel3];
            _textLabel3.userInteractionEnabled = YES;
            _replyNameLabel3.userInteractionEnabled = YES;
            [_replyNameLabel3 release];
            
            UITapGestureRecognizer *replyPress3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(seeProfile:)];
            [_replyNameLabel3 addGestureRecognizer:replyPress3];
            
            
            //时间
            _timeLabel3 = [[UILabel alloc]initWithFrame:CGRectZero];
            _timeLabel3.backgroundColor = [UIColor clearColor];
            _timeLabel3.textAlignment = kTextAlignmentRight;
            _timeLabel3.font = [UIFont boldSystemFontOfSize:13];
            _timeLabel3.textColor = [UIColor lightGrayColor];
            [self.commentView addSubview:_timeLabel3];
            [_timeLabel3 release];
            
            _lineView3 = [[UIView alloc] initWithFrame:CGRectZero];
            _lineView3.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
            [self.commentView addSubview:_lineView3];
            [_lineView3 release];
            
            //评论总数
//                    _numLabel = [[UILabel alloc]initWithFrame:CGRectZero];
//                    _numLabel.backgroundColor = [UIColor clearColor];
//                    _numLabel.font = [UIFont boldSystemFontOfSize:13];
//                    _numLabel.textColor = [UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:1];
//                    [self.commentView addSubview:_numLabel];
//                    [_numLabel release];
            
            _commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            _commentBtn.frame = CGRectZero;
            [_commentBtn setTitleEdgeInsets:UIEdgeInsetsMake(1, 8, 1, 1)];
            _commentBtn.backgroundColor = [UIColor clearColor];
            [_commentBtn setBackgroundImage:[UIImage imageNamed:@"commentNum.png"] forState:UIControlStateNormal];
            [_commentBtn setTitleColor:[UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:1] forState:UIControlStateNormal];
            [self.commentView addSubview:_commentBtn];
            
            _zanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            _zanBtn.backgroundColor = [UIColor clearColor];
            [_zanBtn setBackgroundImage:[UIImage imageNamed:@"zanNum.png"] forState:UIControlStateNormal];
            [_zanBtn setTitleEdgeInsets:UIEdgeInsetsMake(1, 8, 1, 1)];
            [_zanBtn setTitleColor:[UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:1] forState:UIControlStateNormal];
            [self.commentView addSubview:_zanBtn];
            
                    _lineView4 = [[UIView alloc] initWithFrame:CGRectZero];
                    _lineView4.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
                    [self.commentView addSubview:_lineView4];
                    [_lineView4 release];
            
            //拨打电话用的webView
            phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];// 这个webView只是一个后台的容易 不需要add到页面上来  效果跟方法二一样 但是这个方法是合法的
        }
      }
    return self;
    
}
-(void)setVIPFlag:(BOOL)_flag
{
    if (_flag)
    {
        NSString *path = [[NSBundle mainBundle] pathForResource:@"verify_vip" ofType:@"png"];
        _vipImageView.image =  [UIImage imageWithContentsOfFile:path];
        [_verify setHidden:NO];
    }

}

#pragma mark - 设置位置
- (void)setDistance:(NSString *)distance aDtime:(NSString *)adtime
{
    _distanceAndTimeLabel.text = distance;
    [_distanceAndTimeLabel sizeToFit];
    [_verify setFrame:CGRectMake(120 + _distanceAndTimeLabel.frame.size.width, 31, 15, 10)];
}
#pragma mark - 点击评论回复的人的名字（RE@**）跳转到个人空间
-(void)seeProfile:(UITapGestureRecognizer *)_tap
{
    NSDictionary *aDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%d",_tap.view.tag/22],@"userid",[NSArray array],@"facelist",nil];
    BanBu_PersonDataViewController *peopleFfofile = [[BanBu_PersonDataViewController alloc] initWithProfile:aDic];
    peopleFfofile.hidesBottomBarWhenPushed = YES;
    UITableView *tableView = (UITableView *)self.superview;
    if(![tableView isKindOfClass:[UITableView class]])
    {
        tableView = (UITableView *)tableView.superview;
    }
    id next = [self nextResponder];
    while(![next isKindOfClass:[UIViewController class]])//这里跳不出来。。。
    {
        next = [next nextResponder];
    }
    [((UIViewController *)next).navigationController pushViewController:peopleFfofile animated:YES];
    [peopleFfofile release];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)dealloc{
    [phoneCallWebView dealloc];
    [super dealloc];
    
}

- (void)setAvatar:(NSString *)avatarUrlStr{
    
    [_iconButton setImageWithURL:[NSURL URLWithString:avatarUrlStr] placeholderImage:[UIImage imageNamed:@"default.png"] andType:1];
    
}

- (void)setHeadImage:(NSString *)headImageUrlStr{
    
    [_headImageView setImageWithURL:[NSURL URLWithString:headImageUrlStr] placeholderImage:[UIImage imageNamed:@"photo_default.png"] andType:0];
}


-(void)playAction:(UITapGestureRecognizer *)tap{
    
    [self performSelector:@selector(play:) withObject:(UIButton *)tap.view];
}

-(void)play:(UIButton *)sender{
    
    if([self.delegate respondsToSelector:@selector(playVoiceButton:)]){
        
        [_delegate performSelector:@selector(playVoiceButton:) withObject:sender];
    }
}

#pragma mark - 点击发广播用户头像或评论的用户的头像跳转到个人空间
-(void)pushProfile:(UIButton *)sender{
    
    if([self.delegate respondsToSelector:@selector(seeProfile:)]){
        
        [_delegate performSelector:@selector(seeProfile:) withObject:sender];
    }
}

-(void)layoutSubviews{
    [super layoutSubviews];
    ((UIView *)[_shadowView.subviews objectAtIndex:0]).frame = CGRectMake(0, 0, 300, _shadowView.frame.size.height);
//    _shadowView.layer.shadowPath = [UIBezierPath bezierPathWithRect:_shadowView.bounds].CGPath;

//    _playButton.frame = CGRectMake( 150-105/2, _shadowView.frame.size.height-26, 105, 26);
//    _commentView.frame = CGRectMake(10, _shadowView.frame.origin.y-140, 300, 140);
    _lineView1.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
    _lineView2.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
    _lineView3.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
    _lineView4.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
    if(self.highlighted){
        bkView.layer.shadowOffset = CGSizeMake(0, 0);
        bkView.layer.shadowOpacity = 0.9;
        bkView.layer.shadowPath = [UIBezierPath bezierPathWithRect:_shadowView.bounds].CGPath;
        bkView.layer.shadowColor = [[UIColor cyanColor] CGColor];
    }else{
        bkView.layer.shadowOffset = CGSizeMake(0, 2);
        bkView.layer.shadowOpacity = 0.6;
        bkView.layer.shadowPath = [UIBezierPath bezierPathWithRect:_shadowView.bounds].CGPath;
        bkView.layer.shadowColor = [[UIColor blackColor] CGColor];
     }


}

-(void)callThePhoneNumber{
    if(_telButton.frame.size.height!=0)
    {
        NSString *phoneNum = _telButton.titleLabel.text;// 电话号码
        
        NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNum]];
        
        
        [phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];
    }
}
-(void)goToUrl:(UIButton *)sender
{
    if(_netAdress.frame.size.height!=0)
    {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:sender.titleLabel.text]];
    }

}
- (void)setAge:(NSString *)age sex:(NSString *)sex verify:(BOOL)verify
{
    if (!verify)
    {
        _verify.hidden = YES;
        NSString *path = [[NSBundle mainBundle] pathForResource:@"verify_normal" ofType:@"png"];
        _vipImageView.image =  [UIImage imageWithContentsOfFile:path];
    }
    else
    {
        _verify.hidden = NO;
        NSString * verifySource = [NSString stringWithFormat:@"verify_%@",sex];
        NSString *path = [[NSBundle mainBundle] pathForResource:verifySource ofType:@"png"];
        _vipImageView.image =  [UIImage imageWithContentsOfFile:path];
    }
    NSString *sexpath = [[NSBundle mainBundle] pathForResource:sex ofType:@"png"];
    _sexImgV.image =  [UIImage imageWithContentsOfFile:sexpath];
    _ageLabel.text = age;
    [_sexImgV setFrame:CGRectMake(68 + _distanceAndTimeLabel.frame.size.width + 10, 30, 13, 13)];
    [_ageLabel setFrame:CGRectMake(84 + _distanceAndTimeLabel.frame.size.width + 10, 29, 50, 16)];
}

+(NSString *)subString:(NSString *)_str toSize:(CGSize)_size withFont:(UIFont*)_font
{
    NSString *tarStr = [NSString stringWithFormat:@"%@",_str];
    CGSize originSize = [tarStr sizeWithFont:_font constrainedToSize:CGSizeMake(_size.width,1000) lineBreakMode:kTextLineBreakByWordWrapping];
    NSMutableString *completeString  = [[NSMutableString alloc] init];
    @autoreleasepool {
        while(originSize.height>_size.height)
        {
            tarStr = [tarStr substringToIndex:tarStr.length-4];
            originSize = [tarStr sizeWithFont:_font constrainedToSize:CGSizeMake(_size.width,1000) lineBreakMode:kTextLineBreakByWordWrapping];
        }
        [completeString appendFormat:@"%@",[tarStr stringByReplacingCharactersInRange:NSMakeRange(tarStr.length-3, 3) withString:@"..."]];
    }

    return completeString;
}
+(NSString *)replaceStringWithEqualLengthBlank:(NSString *)_orgStr and:(NSString *)_replaceStr font:(UIFont *)_font
{
    NSString *blank = @"                                                                                                                    ";
    NSString *str = [_replaceStr stringByReplacingOccurrencesOfString:_replaceStr withString:[blank substringToIndex:_replaceStr.length]];
    NSLog(@"%@ %@",_orgStr,_replaceStr);
    
    CGFloat w = [_replaceStr sizeWithFont:_font constrainedToSize:CGSizeMake(10000, 20) lineBreakMode:kTextLineBreakByWordWrapping].width;
    CGFloat wBlank = [str sizeWithFont:_font constrainedToSize:CGSizeMake(10000, 20) lineBreakMode:kTextLineBreakByWordWrapping].width;
     NSLog(@"AAA%f %f",wBlank,w);
    int t= 0;
    int index = 0;
    NSMutableString *completeString  = [[NSMutableString alloc] init];
    @autoreleasepool
    {
        while (fabs(w-wBlank)>1)
        {
            
            NSLog(@"%f %d",w-wBlank,t);
            if((w-wBlank)*t<0)
            {
                break;
            }
             t = w-wBlank;
            if(w>wBlank)
            {
                str = [str stringByAppendingString:@" "];
            }
            else
            {
                str = [str substringToIndex:str.length-1];
            }
            wBlank = [str sizeWithFont:_font constrainedToSize:CGSizeMake(10000, 20) lineBreakMode:kTextLineBreakByWordWrapping].width;
            
            if(index>500)
            {
                break;
            }
            index ++;
        }
        [completeString appendFormat:@"%@",[_orgStr stringByReplacingOccurrencesOfString:_replaceStr withString:str]];
    }
    NSLog(@"%@",completeString);
    return completeString;
    
    
}
- (void)setReplySayText1:(NSDictionary *)_content
{
    _replyCellHeight = 0;
    _nameLabel1.frame = CGRectMake(55, 10, 100, 17);
    _textLabel1.frame = CGRectMake(55, 27, 160+75, 17);
    _lineView1.frame = CGRectMake(0, 0, 300, 1);
    _iconBtn1.frame = CGRectMake(10, 10, 35, 35);

    if([[_content valueForKey:@"topname"] length])
    {
        _replyNameLabel1.text = [NSString stringWithFormat:@"RE @%@",[_content valueForKey:@"topname"]];

        float replyNameHeight = [_replyNameLabel1.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(120, 1000) lineBreakMode:NSLineBreakByTruncatingMiddle].height;
        
        if(replyNameHeight >16)
        {
          _replyNameLabel1.text = [BanBu_DigiCell subString:_replyNameLabel1.text toSize:CGSizeMake(120, 16) withFont:[UIFont systemFontOfSize:13]];
        }
        _replyNameLabel1.text = [NSString stringWithFormat:@"%@: ",_replyNameLabel1.text];

        
        
        
        float replyNameWidth = [_replyNameLabel1.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 17) lineBreakMode:NSLineBreakByTruncatingMiddle].width;
        
        
        _replyNameLabel1.frame = CGRectMake(55, 27, replyNameWidth, 17);
        _replyNameLabel1.tag = [[_content valueForKey:@"touid"] integerValue]*22;
    }
    else
    {
        _replyNameLabel1.tag   = 0;
        _replyNameLabel1.frame = CGRectZero;
        _replyNameLabel1.text = @"";
    }
    
    
    NSString *sayText = [NSString stringWithFormat:@"%@%@",_replyNameLabel1.text,[_content valueForKey:@"saytext"]];
    _textLabel1.text = sayText;
    float textLabelHeight = [sayText sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 100) lineBreakMode:kTextLineBreakByWordWrapping].height;
    NSLog(@"%@ %f",sayText,textLabelHeight);
    if(textLabelHeight >32)
    {
         sayText = [BanBu_DigiCell subString:sayText toSize:CGSizeMake(235, 32) withFont:[UIFont systemFontOfSize:13]];
    }
    _textLabel1.text = sayText;
    if(_replyNameLabel1.text.length)
    {
        _textLabel1.text = [BanBu_DigiCell replaceStringWithEqualLengthBlank:sayText and:_replyNameLabel1.text font:[UIFont systemFontOfSize:13]];
    }

    
    
    textLabelHeight = [sayText sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 100) lineBreakMode:kTextLineBreakByWordWrapping].height;
    NSLog(@"%@ %f",sayText,textLabelHeight);
    _textLabel1.frame = CGRectMake(55, 27, 235, textLabelHeight);

    _replyCellHeight += textLabelHeight+38;

}
- (void)setReplySayText2:(NSDictionary *)_content
{
     _lineView2.frame = CGRectMake(0, _replyCellHeight-1, 300, 1);
    _iconBtn2.frame = CGRectMake(10, 10+_replyCellHeight, 35, 35);
    _nameLabel2.frame = CGRectMake(55, 10+_replyCellHeight, 100, 17);
    _textLabel2.frame = CGRectMake(55, 27+_replyCellHeight, 160+75, 17);
    
    
    if([[_content valueForKey:@"topname"] length])
    {
        _replyNameLabel2.text = [NSString stringWithFormat:@"RE @%@",[_content valueForKey:@"topname"]];
//        NSLog(@"%@ %d",_replyNameLabel2.text,_replyNameLabel2.text.length);
        float replyNameHeight = [_replyNameLabel2.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(120, 1000) lineBreakMode:NSLineBreakByTruncatingMiddle].height;
        
        if(replyNameHeight >16)
        {
            _replyNameLabel2.text = [BanBu_DigiCell subString:_replyNameLabel2.text toSize:CGSizeMake(120, 16) withFont:[UIFont systemFontOfSize:13]];
        }
        _replyNameLabel2.text = [NSString stringWithFormat:@"%@: ",_replyNameLabel2.text];
        float replyNameWidth = [_replyNameLabel2.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 17) lineBreakMode:NSLineBreakByTruncatingMiddle].width;
        _replyNameLabel2.frame = CGRectMake(55, 27+_replyCellHeight, replyNameWidth, 17);
        _replyNameLabel2.tag = [[_content valueForKey:@"touid"] integerValue]*22;
    }
    else
    {
        _replyNameLabel2.tag   = 0;
        _replyNameLabel2.frame = CGRectZero;
        _replyNameLabel2.text = @"";
    }
    
    
    NSString *sayText = [NSString stringWithFormat:@"%@%@",_replyNameLabel2.text,[_content valueForKey:@"saytext"]];
    _textLabel2.text = sayText;
    float textLabelHeight = [sayText sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 100) lineBreakMode:kTextLineBreakByWordWrapping].height;
    if(textLabelHeight >32)
    {
        sayText = [BanBu_DigiCell subString:sayText toSize:CGSizeMake(235, 32) withFont:[UIFont systemFontOfSize:13]];
    }
    _textLabel2.text = sayText;
    NSLog(@"%@",_textLabel2.text);
    if(_replyNameLabel2.text.length)
    {
        _textLabel2.text = [BanBu_DigiCell replaceStringWithEqualLengthBlank:sayText and:_replyNameLabel2.text font:[UIFont systemFontOfSize:13]];
    }
    NSLog(@"%@",_textLabel2.text);
    textLabelHeight = [sayText sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 100) lineBreakMode:kTextLineBreakByWordWrapping].height;

    _textLabel2.frame = CGRectMake(55, 27+_replyCellHeight, 235, textLabelHeight);
    
    //    _lineView2.frame = CGRectMake(0, textLabelHeight+38-1, 300, 1);
    _replyCellHeight += textLabelHeight+38;

//    _textLabel2.text = [_content valueForKey:@"saytext"];
}
- (void)setReplySayText3:(NSDictionary *)_content
{
//    _textLabel3.text = [_content valueForKey:@"saytext"];
//    cell.lineView3.frame = CGRectMake(0, 55*2, 300, 1);
//    cell.iconBtn3.frame = CGRectMake(10, 10+55*2, 35, 35);
//    cell.nameLabel3.frame = CGRectMake(55, 10+55*2, 100, 17);
//    cell.textLabel3.frame = CGRectMake(55, 27+55*2, 160+75, 17);
    _lineView3.frame = CGRectMake(0, _replyCellHeight-1, 300, 1);
    _iconBtn3.frame = CGRectMake(10, 10+_replyCellHeight, 35, 35);
    _nameLabel3.frame = CGRectMake(55, 10+_replyCellHeight, 100, 17);
    _textLabel3.frame = CGRectMake(55, 27+_replyCellHeight, 160+75, 17);
    
    
    if([[_content valueForKey:@"topname"] length])
    {
        _replyNameLabel3.text = [NSString stringWithFormat:@"RE @%@",[_content valueForKey:@"topname"]];
//        NSLog(@"%@ %d",_replyNameLabel3.text,_replyNameLabel3.text.length);
        float replyNameHeight = [_replyNameLabel3.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(120, 1000) lineBreakMode:NSLineBreakByTruncatingMiddle].height;
        
        if(replyNameHeight >16)
        {
            _replyNameLabel3.text = [BanBu_DigiCell subString:_replyNameLabel3.text toSize:CGSizeMake(120, 16) withFont:[UIFont systemFontOfSize:13]];
        }
        _replyNameLabel3.text = [NSString stringWithFormat:@"%@: ",_replyNameLabel3.text];
        float replyNameWidth = [_replyNameLabel3.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 17) lineBreakMode:NSLineBreakByTruncatingMiddle].width;
        _replyNameLabel3.frame = CGRectMake(55, 27+_replyCellHeight, replyNameWidth, 17);
        _replyNameLabel3.tag = [[_content valueForKey:@"touid"] integerValue]*22;
    }
    else
    {
        _replyNameLabel3.tag   = 0;
        _replyNameLabel3.frame = CGRectZero;
        _replyNameLabel3.text = @"";
    }
    
    
  
    NSString *sayText = [NSString stringWithFormat:@"%@%@",_replyNameLabel3.text,[_content valueForKey:@"saytext"]];
    _textLabel3.text = sayText;
    float textLabelHeight = [sayText sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 100) lineBreakMode:kTextLineBreakByWordWrapping].height;
    if(textLabelHeight >32)
    {
        sayText = [BanBu_DigiCell subString:sayText toSize:CGSizeMake(235, 32) withFont:[UIFont systemFontOfSize:13]];
    }
    _textLabel3.text = sayText;
    if(_replyNameLabel3.text.length)
    {
        _textLabel3.text = [BanBu_DigiCell replaceStringWithEqualLengthBlank:sayText and:_replyNameLabel3.text font:[UIFont systemFontOfSize:13]];
    }
    textLabelHeight = [sayText sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(235, 100) lineBreakMode:kTextLineBreakByWordWrapping].height;
//    NSLog(@"%@ %f",sayText,textLabelHeight);
    _textLabel3.frame = CGRectMake(55, 27+_replyCellHeight, 235, textLabelHeight);
    NSLog(@"%@",NSStringFromCGRect(_textLabel3.frame));


//    NSLog(@"%@ %@",NSStringFromCGRect(_replyNameLabel3.frame),NSStringFromCGRect(_textLabel3.frame));
    //    _lineView2.frame = CGRectMake(0, textLabelHeight+38-1, 300, 1);
    _replyCellHeight += textLabelHeight+38;
}


-(void)cancelImageLoad
{
    [_iconButton cancelCurrentImageLoad];
    [_headImageView cancelCurrentImageLoad];
    
}
@end
